﻿<%@ WebHandler Language="C#" Class="Admin_AddEdit" %>

using System;
using System.Web;
using System.Web.SessionState;

public class Admin_AddEdit : IHttpHandler
{
    public void ProcessRequest (HttpContext context) {

        /* 管理员信息验证 */
        int Admin_My_Id =Admins.IsLogin();
        if (Admin_My_Id<1)
            Utils.ShowEnd(context, -2);

        /* 外部数据接受 */
        //Utils.ShowEnd(context, context.Request.Params["Admin_Id"].ToString().Trim());
        int Obj_Admin_Id = Convert.ToInt32(context.Request.Params["Obj_Admin_Id"].ToString().Trim());
        int Edit_Mode = Convert.ToInt32(context.Request.Params["Edit_Mode"].ToString().Trim());
        int Admin_Level = Convert.ToInt32(context.Request.Params["Admin_Level"].ToString().Trim());
        int Admin_Group = Convert.ToInt32(context.Request.Params["Admin_Group"].ToString().Trim());
        int Activation = Convert.ToInt32(context.Request.Params["Activation"].ToString().Trim());
        int Cookie_Time = Convert.ToInt32(context.Request.Params["Cookie_Time"].ToString().Trim());
        int Lang = Convert.ToInt32(context.Request.Params["Lang"].ToString().Trim());
        string Admin_Name = context.Request.Params["Admin_Name"].ToString().Trim();
        string IP_Area = context.Request.Params["IP_Area"].ToString().Trim();
        string Admin_Remark = context.Request.Params["Admin_Remark"].ToString().Trim();
        string Admin_Introduction = context.Request.Params["Admin_Introduction"].ToString().Trim();
        string Admin_Email = context.Request.Params["Admin_Email"].ToString().Trim();
        string Admin_Phone = context.Request.Params["Admin_Phone"].ToString().Trim();
        string Admin_Office_Tel = context.Request.Params["Admin_Office_Tel"].ToString().Trim();

        /* 完整性验证 */
        Verification verification=new Verification();
        if (!verification.VerificationMinMaxValue(Edit_Mode, 0, 1))
            Utils.ShowEnd(context, -1);
        if (!verification.VerificationMinMaxValue(Obj_Admin_Id, 0, 1999))
            Utils.ShowEnd(context, -1);
        if (!verification.VerificationMinMaxValue(Admin_Level, 1, 99))
            Utils.ShowEnd(context, -1);
        if (!verification.VerificationMinMaxValue(Admin_Group, 1, 32000))
            Utils.ShowEnd(context, -1);
        if (!verification.VerificationMinMaxLength(Admin_Name,2,254))
            Utils.ShowEnd(context, -1);
        if (!verification.Reg(IP_Area, verification.Ip))
            Utils.ShowEnd(context, -1);

        Admins admin = new Admins();
        Utils.ShowEnd(context, admin.AddEdit(Edit_Mode, Obj_Admin_Id, Admin_Name, Admin_Group, Admin_Level, Activation, IP_Area, Cookie_Time, Admin_Remark, Admin_Introduction, Admin_Email, Admin_Phone, Admin_Office_Tel, Lang,Admin_My_Id));
        
       
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}